// eslint-disable-next-line no-unused-vars
import VXETable, { Column } from 'vxe-table'
import isNil from 'lodash/isNil'

VXETable.renderer.add('Normal', {
  renderDefault(h, renderOpts, { row, column }) {
    const rawValue = row[column.property]
    const { formatter } = renderOpts
    let cellValue = rawValue
    if (isNil(rawValue) || String(rawValue).trim() === '') {
      cellValue = '--'
    } else if (formatter) {
      cellValue = formatter({ cellValue: rawValue, row, column })
    }
    return [<span>{cellValue}</span>]
  }
})

/**@type { Column } */
export const options = {
  showOverflow: 'tooltip'
}
